package com.briup.jdbc.execute;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class DeleteExecute<T> extends AbstractExecute {

	public DeleteExecute() {
		super();
	}

	public DeleteExecute(String sql, Class param, Object[] params) {
		super(sql, param, params);
	}

	public DeleteExecute(String sql, Class param) {
		super(sql, param);
	}

	// 主要方法
	public int delete(Connection conn) throws Exception {
		int result = -1;
		try {

			PreparedStatement ps = conn.prepareStatement(sql);
			if (params != null) {
				for (int i = 0; i < params.length; i++) {
					ps.setObject(i + 1, params[i]);
				}
			}
			result = ps.executeUpdate();
		} catch (Exception e) {
			throw e;
		}
		return result;
	}

}
